/**
 * 
 */
package huajiu.com.dao;

import java.util.List;

import huajiu.com.base.BaseDao;
import huajiu.com.domain.User;

import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author ItBotPjq
 *2018年1月24日
 */
@Repository
@Transactional
public class UserDao {
	
	
	@Autowired
	private BaseDao<User> baseDao;
	
	
	public User selectUserByMid(String userMid){
		String sqlString ="select u.* from user u where name = :name ";
		return (User) baseDao.getCurrentSession().createSQLQuery(sqlString).addEntity(User.class).setParameter("name", "33").list().get(0);
	}
	
	public boolean checkMid(String mid){
		String hql ="from User where mid = ? ";
		Query query = baseDao.getCurrentSession().createQuery(hql);
		query.setParameter(0,mid );
		List<User> list =query.list();
		return list.size()>0;
	}

}
